home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / segal / mask_log.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-24  |  4.5 KB  |  221 lines

  1. /*
  2.  *    mask_log.c    For mask type selection
  3.  *
  4.  */
  5.  
  6. #include "common.h"
  7.  
  8. /*****************************************************/
  9. void
  10. add_to_mask_log(index)
  11. int index;
  12. {
  13.     char *mask_list_string();
  14.     void select_mask_in_list();
  15.  
  16.     char foo[80];
  17.  
  18.     /* add a mask's filename to the mask log */
  19.     if(index == 0) {
  20.         segal.e_m = 0;
  21.         sprintf(foo, "Mask: %s", m[0].fname);
  22.         xv_set(View_win->msg_mask,
  23.             PANEL_LABEL_STRING, foo,
  24.             NULL);
  25.         xv_set(Paint_win_paint->msg_mask,
  26.             PANEL_LABEL_STRING, foo,
  27.             NULL);
  28.         m[index].mask_type = MASK_EDIT;
  29.         m[index].mask_hue = MASK_GREEN;
  30.  
  31.         /* activate mask ui stuff */
  32.  
  33.         xv_set(View_win->but_segment,
  34.             PANEL_INACTIVE, FALSE,
  35.             NULL);
  36.  
  37.     }
  38.     else {
  39.         m[index].mask_type = MASK_NO_APPLY;
  40.         m[index].mask_hue = MASK_BLUE;
  41.     }
  42.     (void) xv_set(Mask_log_pop_mask_log->ls_mask_filenames,
  43.         PANEL_LIST_INSERT, index,
  44.         PANEL_LIST_STRING, index,
  45.             mask_list_string(index),
  46.         PANEL_LIST_SELECT, index,
  47.             TRUE,
  48.         NULL);
  49.  
  50.     if(index == 0) {
  51.         xv_set(Mask_log_pop_mask_log->ls_mask_filenames,
  52.             PANEL_LIST_SELECT, 0,
  53.                 TRUE,
  54.             NULL);
  55.         select_mask_in_list(mask_list_string(0));
  56.     }
  57.  
  58.     sprintf(foo, "Masks Loaded: %3d", index + 1);
  59.     (void) xv_set(Mask_log_pop_mask_log->msg_masks_loaded,
  60.         PANEL_LABEL_STRING, foo,
  61.         NULL);
  62. }
  63.  
  64. /*****************************************************/
  65. char
  66. *mask_list_string(mnum)
  67. int mnum;
  68. {
  69.     char foo[80];
  70.  
  71.     switch(m[mnum].mask_type) {
  72.     case MASK_NO_APPLY :
  73.         strcpy(foo, "<0> ");
  74.         break;
  75.     case MASK_EDIT :
  76.         strcpy(foo, "<E> ");
  77.         break;
  78.     case MASK_EXCLUSIVE :
  79.         strcpy(foo, "<-> ");
  80.         break;
  81.     case MASK_INCLUSIVE :
  82.         strcpy(foo, "<+> ");
  83.         break;
  84.     default:
  85.         break;
  86.     }
  87.  
  88.     strcat(foo, m[mnum].fname);
  89.     return(foo);
  90. }
  91.  
  92. /*****************************************************/
  93. int
  94. find_mask_in_list(string)
  95. char *string;
  96. {
  97.     int i;
  98.  
  99.     for(i = 0; i < segal.num_m; i++) {
  100.         if(strcmp(m[i].fname, &string[4]) == 0)
  101.             return(i);
  102.     }
  103.  
  104.     fprintf(stderr, "Did Not Find In List!\n");
  105.     return(-1); /* Did not find ... shouldn't happen, though */
  106. }
  107.  
  108. /*****************************************************/
  109. void
  110. select_mask_in_list(string)
  111. char *string;
  112. {
  113.     mlog.sel_m = find_mask_in_list(string);
  114.     xv_set(Mask_log_pop_mask_log->set_mask_type,
  115.         PANEL_VALUE, m[mlog.sel_m].mask_type,
  116.         NULL);
  117.     xv_set(File_pop_save_as->text_save_dname,
  118.         PANEL_VALUE, m[mlog.sel_m].dname,
  119.         NULL);
  120.     xv_set(File_pop_save_as->text_save_fname,
  121.         PANEL_VALUE, m[mlog.sel_m].fname,
  122.         NULL);
  123. }
  124.  
  125. /*****************************************************/
  126. void
  127. set_mask_type_proc(value)
  128. int        value;
  129. {
  130.     void    update_states_after_changing_edit_mask();
  131.  
  132.     if(value == MASK_EDIT) {
  133.         /* (Can have at most one Edit Mask at a time) */
  134.         if(m[segal.e_m].mask_type == MASK_EDIT) {
  135.             m[segal.e_m].mask_type = MASK_NO_APPLY;
  136.             xv_set(Mask_log_pop_mask_log->ls_mask_filenames,
  137.                 PANEL_LIST_STRING, segal.e_m,
  138.                     mask_list_string(segal.e_m),
  139.                 NULL);
  140.         }
  141.  
  142.         segal.e_m = mlog.sel_m;
  143.         update_states_after_changing_edit_mask();
  144.     }
  145.  
  146.     m[mlog.sel_m].mask_type = value;
  147.     xv_set(Mask_log_pop_mask_log->ls_mask_filenames,
  148.         PANEL_LIST_STRING, mlog.sel_m,
  149.             mask_list_string(mlog.sel_m),
  150.         NULL);
  151. }
  152.  
  153. /*****************************************************/
  154. void
  155. set_mask_hue(item, value, event)
  156. Panel_item      item;
  157. int        value;
  158. Event           *event;
  159. {
  160.     m[mlog.sel_m].mask_hue = value;
  161. }
  162.  
  163. /*****************************************************/
  164. void
  165. make_edit_mask_defined(event)
  166. Event           *event;
  167. {
  168.     void set_mask_type_proc();
  169.  
  170.     int i, found;
  171.  
  172.     if(segal.num_m == 0) return;
  173.  
  174.     if(event_id(event) == LOC_WINEXIT) {
  175.         /* Make sure one of the masks is of mask_type MASK_EDIT ... */
  176.         found = FALSE;
  177.         for(i = 0; i < segal.num_m; i++)
  178.             if(m[i].mask_type == MASK_EDIT)
  179.                 found = TRUE;
  180.         if(!found) {
  181.             /* Pop up a warning box, stay in, make 'em pick one */
  182.             /* For Now, Default is m[0] = the edit mask iff there
  183.              * is no other edit mask defined
  184.              */
  185.             mlog.sel_m = 0;
  186.             set_mask_type_proc(NULL, MASK_EDIT, NULL);
  187.             xv_set(Mask_log_pop_mask_log->set_mask_type,
  188.                 PANEL_VALUE, MASK_EDIT,
  189.                 NULL);
  190.             xv_set(Mask_log_pop_mask_log->ls_mask_filenames,
  191.                 PANEL_LIST_SELECT, 0, TRUE,
  192.                 NULL);
  193.             xv_set(File_pop_save_as->text_save_dname,
  194.                 PANEL_VALUE, m[0].dname,
  195.                 NULL);
  196.             xv_set(File_pop_save_as->text_save_fname,
  197.                 PANEL_VALUE, m[0].fname,
  198.                 NULL);
  199.         }
  200.     }
  201. }
  202.  
  203. /*****************************************************/
  204. void
  205. update_states_after_changing_edit_mask()
  206. {
  207.     void redisplay_all();
  208.  
  209.     char foo[80];
  210.  
  211.     if(img.loaded) redisplay_all();
  212.  
  213.     sprintf(foo, "Mask: %s", m[segal.e_m].fname);
  214.     xv_set(View_win->msg_mask,
  215.         PANEL_LABEL_STRING, foo,
  216.         NULL);
  217.     xv_set(Paint_win_paint->msg_mask,
  218.         PANEL_LABEL_STRING, foo,
  219.         NULL);
  220. }
  221.